cmake_minimum_required(VERSION 3.5)

set(VCPKG_TARGET_TRIPLET "x86-windows-static" CACHE STRING "" FORCE)
set(CMAKE_TOOLCHAIN_FILE D:/vcpkg/scripts/buildsystems/vcpkg.cmake)

add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

set(PROJECT_NAME "orangle2")
project(${PROJECT_NAME} LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS_RELEASE "/MT")

add_definitions(-DSDL_MAIN_HANDLED)
add_definitions(-DHV_STATICLIB)

list(APPEND CMAKE_PREFIX_PATH "D:/Qt515/install32/lib/cmake")
include_directories("./src/ui/material")
include_directories("./build/orangle2_autogen/include")
include_directories("./src/ui/widget")

find_package(libhv CONFIG REQUIRED)
find_package(Qt5 COMPONENTS Widgets Network REQUIRED)
find_package(asio CONFIG REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
find_package(FFMPEG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(PahoMqttCpp CONFIG REQUIRED)

file(GLOB_RECURSE SRC "./src/*.cpp")
file(GLOB_RECURSE INC "./src/*.h")
file(GLOB_RECURSE UI "./src/*.ui")
file(GLOB_RECURSE RES "./res/*.qrc")


add_executable(
    ${PROJECT_NAME}
    WIN32
    ${SRC}
    ${INC}
    ${UI}
    ${RES}
)

target_link_libraries(
    ${PROJECT_NAME} PRIVATE
    hv_static
    asio::asio
    Qt5::Widgets
    Qt5::Network
  #  $<TARGET_NAME_IF_EXISTS:SDL2::SDL2main>
    $<IF:$<TARGET_EXISTS:SDL2::SDL2>,SDL2::SDL2,SDL2::SDL2-static>
    nlohmann_json::nlohmann_json
    PahoMqttC::PahoMqttC PahoMqttCpp::paho-mqttpp3-static
)

target_include_directories(
    ${PROJECT_NAME} PRIVATE
    ${FFMPEG_INCLUDE_DIRS}
)

target_link_directories(
    ${PROJECT_NAME} PRIVATE
    ${FFMPEG_LIBRARY_DIRS}
)

target_link_libraries(
    ${PROJECT_NAME} PRIVATE
    ${FFMPEG_LIBRARIES}
)

